﻿/**********************************************************************
 * @file   OperSolve.h
 * @brief  求解操作动作
 * @author liuzhonghua (liuzhonghuaszch@163.com)
 * @date   2024-12-31
 *********************************************************************/
#ifndef _OPER_SOLVE_H___
#define _OPER_SOLVE_H___

#include "FITK_Kernel/FITKCore/FITKActionOperator.h"
#include "FITK_Kernel/FITKCore/FITKOperatorRepo.h"
#include "FITK_Kernel/FITKAppFramework/FITKExecProgramDriver.h"
#include "FITK_Kernel/FITKAppFramework/FITKProgramDriverFactory.h"


namespace GUIOper
{
    /**
     * @brief  求解操作
     * @author liuzhonghua (liuzhonghuaszch@163.com)
     * @date   2024-12-31
     */
    class OperSolve :public Core::FITKActionOperator
    {
        Q_OBJECT
    public:
        explicit OperSolve() = default;
        virtual ~OperSolve() = default;
        /**
         * @brief 界面逻辑，生成UI交互
         * @return true             执行成功
         * @return false            执行失败
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2024-12-31
         */
        virtual bool execGUI() override;
        /**
         * @brief 业务处理逻辑，在execGUI后执行
         * @return true             执行成功
         * @return false            执行失败
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2024-12-31
         */
        virtual bool execProfession() override;

    protected:
        /**
         * @brief    求解操作
         * @return   void
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2024-12-31
         */
        void solverOper();
        /**
         * @brief    导入结果数据
         * @return   void
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-02-13
         */
        void importResult();
        /**
         * @brief    导入hdf5结果数据
         * @param[i] file
         * @return   void
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-02-13
         */
        void importResultHDF5(QString file);
        /**
         * @brief    导入csv结果数据
         * @param[i] file
         * @return   void
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-02-13
         */
        void importResultCSV(QString file);

        void clearPostData();

        void ioHDF5IOThreadFinishedSlot();

    };
    // 按钮注册相关操作
    Register2FITKOperatorRepo(actionSolveSolve, OperSolve);


    /**
     * @brief  求解器
     * @author liuzhonghua (liuzhonghuaszch@163.com)
     * @date   2024-12-31
     */
    class SEADriver : public AppFrame::FITKExecProgramDriver
    {
        Q_OBJECT
    public:
        explicit SEADriver() ;
        virtual ~SEADriver();
        /**
         * @brief    是否存在求解器
         * @return   bool
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2024-12-31
         */
        bool isExistSolver();
        /**
         * @brief    程序类型
         * @return   int
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2024-12-31
         */
        int getProgramType() override;
        /**
         * @brief    程序名称
         * @return   QString
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2024-12-31
         */
        QString getProgramName() override;

    protected:
    private:
    };
    Register2FITKProgramDriverFactory(2, SEASolver, SEADriver);
    /**
     * @brief 求解器驱动输入信息类
     * @author liuzhonghua (liuzhonghuaszch@163.com)
     * @date   2024-12-31
     */
    class SEASolverInfo : public AppFrame::FITKProgramInputInfo
    {
    public:
        explicit SEASolverInfo() = default;
        virtual ~SEASolverInfo();
        /**
         * @brief    设置求解文件
         * @param[i] needSolerFile 
         * @return   void
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2024-12-31
         */
        void setNeedSolveFile(QString needSolerFile);
        /**
         * @brief    设置结果文件
         * @param[i] resultFile 
         * @return   void
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2024-12-31
         */
        void setResultFile(QString resultFile);
        /**
         * @brief    设置求解类型
         * @param[i] type 
         * @return   void
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-02-13
         */
        void setSolverType(QString type);
        /**
         * @brief 获取启动参数
         * @return QStringList
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2024-12-31
         */
        QStringList args() override;
    protected:
    private:
        /**
         * @brief  需要求解的文件路径
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2024-12-31
         */
        QString _needSolverFile{};
        /**
         * @brief  结果文件路径
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2024-12-31
         */
        QString _resultFile{};
        /**
         * @brief  求解器类型
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2025-02-13
         */
        QString _solverType{};
    };
}


#endif
